var userInfo;
Jes.extend({
	userSess : function(type){
		Jes.sync(function(){Jes.action("getUserSess",false,function(da){userInfo = da;});});
		if(!userInfo){
			if(type == 1) alert("Session过期，请重新登入！"),parent.Jes.url("../../jesacl/html/login.html");
			else Jes.url('error.html');
			return false;
		}else{
			return true;
		}
	}
	,isFlowAdmin : function(){
		return userInfo.roles.indexOf('flowadmin')!=-1;
	}
	,syncFmenu : function(){
		Jes.save('jes.syncfmenu',{param:{},isLoad:0},function(da){alert(da);});
	}
	//通用选择栏目的方法
	,Menu :{
		show : function(fmenuid){
			Jes.action('getFmenuTree@App',{type:'checkbox',disabled:'0',only:'1',upD:2},function(data){
				Jes.html('fmenu_tree',data);
				treeObj = new JSDragDropTree();
				//treeObj.setImageFolder('../../components/drag-drop-folder-tree/images/');//设置图片路径
				treeObj.setTreeId('dhtml_tree');
				treeObj.setMaximumDepth(10);
				//treeObj.setUserFunctionAfterDropDragableNodes(function(id,pId){changeParent(id,pId)});
				treeObj.setMessageMaximumDepthReached('超过最多级别'); // If you want to show a message when maximum depth is reached, i.e. on drop.
				treeObj.initTree();
				treeObj.expand();
				//treeObj.expandAll();
			});
		}
		,open : function(){
			Jes.FlyDiv.show("mdiv",null,null);
		}
		,sel : function(){
			//显示栏目名称
			var cks= Jes.name('tree.fmenuid'),el,name='',id='';
			Jes.each(cks,function(i){
				el = cks[i];
				if(el.checked){
					id+=(name==''?'':',')+"'"+el.value+"'";
					name+=(name==''?'':' ')+'<span style="background-color:#8ce3be;padding:5px;color:#fff">'+el.nodename+'</span>';
				}
			});
			Jes.val('menu',name);
			Jes.val('menuid',id);
			Jes.FlyDiv.hide();
		}
	}
});

//所有下拉框
Jes.Select={
	css : function(el,param){
		Jes.sel(el,"topcss_query_sql@sel",param);
	}
	,link : function(isAll){
		this._dic("type",{"keytype":"LINK"},isAll);
	}
	,ask : function(role){
		this._dic("type",{"keytype":"ASK",'role':role||''});
	}
	,video : function(){
		this._dic("type",{"keytype":"VIDEO"});
	}
	,voteGroup : function(el,param){
		Jes.sel(el,"votegroup_query_sql@sel",param);
	}
	,role : function(el,param){
		Jes.sel(el,"aclrole_query_sql@sel",param);
	}
	,_dic : function(el,param,isAll){//此方法名需要优化
		Jes.sel(el,"acldic_query_sql@sel",param,isAll);
	}
}